package dt.board.qna;


import com.opensymphony.xwork2.ActionSupport;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

import java.io.Reader;
import java.io.File;
import java.io.IOException;
import java.util.Map;

import org.apache.commons.io.FileUtils;
import org.apache.struts2.interceptor.SessionAware;

public class qnaModifyAction extends ActionSupport implements SessionAware{
	private Map session;
	public static Reader reader;
	public static SqlMapClient sqlMapper;
	
	private qnaBoardVO paramClass;
	private qnaBoardVO resultClass;
	
	private int currentPage;
	
	private int no;
	private String subject;
	private String name;
	private String password;
	private String content;

	
	public qnaModifyAction() throws IOException
	{
		reader = Resources.getResourceAsReader("sqlMapConfig.xml");
		sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
		reader.close();
		
	}
	
	public String execute() throws Exception
	{
		paramClass = new qnaBoardVO();
		resultClass = new qnaBoardVO();
		
		paramClass.setNo(getNo());
		paramClass.setSubject(getSubject());
		paramClass.setName(getName());
		paramClass.setPassword(getPassword());
		paramClass.setContent(getContent());
		
		sqlMapper.update("qna.updateBoard", paramClass);
		

		
		resultClass = (qnaBoardVO) sqlMapper.queryForObject("qna.selectOne", getNo());
		return SUCCESS;
		
		
	}

	public qnaBoardVO getParamClass() {
		return paramClass;
	}

	public void setParamClass(qnaBoardVO paramClass) {
		this.paramClass = paramClass;
	}

	public qnaBoardVO getResultClass() {
		return resultClass;
	}

	public void setResultClass(qnaBoardVO resultClass) {
		this.resultClass = resultClass;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getNo() {
		return no;
	}

	public void setNo(int no) {
		this.no = no;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Map getSession() {
		return session;
	}

	public void setSession(Map session) {
		this.session = session;
	}


	
}
